package com.jiangli.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;

import java.time.Duration;

/**
 * Web配置类，配置WebClient和其他Web相关组件
 */
@Configuration
public class DouBaoConfiguration {

    /**
     * 配置WebClient，用于发送HTTP请求
     */
    @Bean
    public WebClient webClient() {
        // 配置HTTP客户端，设置超时时间
        HttpClient httpClient = HttpClient.create()
                .responseTimeout(Duration.ofSeconds(30)); // 响应超时30秒

        return WebClient.builder()
                .clientConnector(new ReactorClientHttpConnector(httpClient))
                .build();
    }
}
